import socket

# 创建UDP socket对象
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# 发送数据
client_socket.sendto('Hello, server!'.encode(encoding='utf-8'), ('localhost', 8000))

# 接收数据
data, addr = client_socket.recvfrom(1024)
print('Received message: %s from %s' % (data.decode(), addr))
